package ynu.edu.Service.Impl;

import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import ynu.edu.Dao.DeviceDao;
import ynu.edu.Dao.WaterDao;
import ynu.edu.Entity.Device;
import ynu.edu.Entity.Water;
import ynu.edu.Service.ISensorService;

import java.util.Date;
import java.util.List;

@Service
public class WaterService implements ISensorService {
    @Resource
    DeviceDao deviceDao;
    @Resource
    WaterDao waterDao;
    @Override
    public void insert(Double value){
        Water water = new Water();
        Device device = deviceDao.getReferenceById(1L);
        water.setDevice(device);
        water.setValue(value);

        waterDao.save(water);
    }
    @Override
    public Double getValue(){
        Water water = waterDao.findFirstByOrderByCreateTimeDesc().get();
        return water.getValue();
    }
    @Override
    public List<Double> getValuesFromLastDay(){
        return null;
    }
    @Override
    public List<Date> getTimeFromLastDay(){
        return null;
    }
}
